const axios = require('./axios');
const { ownerAndRepo } = require('./tool');

module.exports = {
  /**
   * 获取目录Tree
   * @link https://gitee.com/api/v5/swagger#/getV5ReposOwnerRepoGitTreesSha
   **/
  trees: (option = {}) => {
    return axios.get(`repos/${ownerAndRepo(option)}/git/trees/${option.sha}`, {
      params: option
    })
  },
  /**
   * 获取文件Blob
   * @link https://gitee.com/api/v5/swagger#/getV5ReposOwnerRepoGitBlobsSha
   **/
  blobs: (option = {}) => {
    return axios({
      method: 'get',
      url: `repos/${ownerAndRepo(option)}/git/blobs/${option.sha}`,
      params: option
    })
  },
};